--[[/**
-- * 
 * 阿尔萨 技能3
 * 对同一目标每造成1次伤害，伤害提升2%，效果最多叠加10层。更换目标后，效果重置。
-- *
-- */]]

---@class BuffEffect125100 : BaseBuffEffect
BuffEffect125100 = ClientFight.CreateClass("BuffEffect125100", ClientFight.BaseBuffEffect)
local t = BuffEffect125100
t.BUFF_EFFECT_125100_ATTACK_TARGET = "BUFF_EFFECT_125100_ATTACK_TARGET";
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    
    local parameters = {...};
    local fighter = buff.target;
    local target = parameters[1];

    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]阿尔萨技能3被动触发 %s的buff%s 被攻击者%s",
            fight.frame,fighter.fighterId,buff.modelId,target.fighterId)
    );

    local effectVals = buff.buffBean.f_BuffEffectValue;
    -- 上一次攻击的fightId
    local lastTargetFightId =  buff.effectParams[t.BUFF_EFFECT_125100_ATTACK_TARGET] or  0;
    if (lastTargetFightId == 0 or lastTargetFightId == target.fighterId) then
    BuffManager.addBuff(fight, buff.skill, fighter, fighter, false, effectVals[1], effectVals[2], parameters);
     else 
    local oldBuff = BuffManager.getBuffByModel(fighter, effectVals[1]);
    if (oldBuff ~= nil) then
    BuffManager.removeFighterBuff(fight, fighter, oldBuff, true, parameters);
    end
    BuffManager.addBuff(fight, buff.skill, fighter, fighter, false, effectVals[1], effectVals[2], parameters);
    end

    buff.effectParams[t.BUFF_EFFECT_125100_ATTACK_TARGET] = target.fighterId;
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()